<template>
  <div class="news">
    <div class="news-imgs">
      <img class="img" src="@/assets/img/waitfome.webp" alt="" />
    </div>
    <div class="news-list">
      <div class="left">
        <div v-for="(item, index) in newList" :key="index" class="item">
          <el-icon><Guide /></el-icon>
          <a :href="item.link" class="content" target="_blank">{{
            item.title
          }}</a>
          <div class="date">{{ utils.ymd(item.pubtime) }}</div>
        </div>
      </div>
      <Searchbar />
    </div>
    <Asyncloading>
      <template v-slot>
        <Revideo />
      </template>
    </Asyncloading>
  </div>
</template>

<script lang="ts" setup>
import { defineAsyncComponent, onMounted, ref } from "vue";
import Searchbar from "@/components/common/tabbar/searchbar.vue";
import { getNewList } from "@/server/news";
import utils from "@/utils/utils";
//异步组件加载器
import Asyncloading from "@/components/common/AsyncComp/asyncloading.vue";
//异步加载组件
const Revideo = defineAsyncComponent(
  () => import("@/components/common/AsyncComp/revideo.vue")
);
const newList = ref<any>([]);
onMounted(async () => {
  await getNesList();
});

const getNesList = () => {
  getNewList().then((res: any) => {
    newList.value = res.list.splice(0, 6);
  });
};
</script>
<style lang="less" scoped>
.news {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto;
  &-imgs {
    width: 100%;
    height: 400px;
    .img {
      width: 100%;
      height: 100%;
    }
  }
  &-list {
    display: flex;
    width: 80%;
    border-radius: 10px;
    margin: 80px 0;
    justify-content: space-between;
    .left {
      width: 71%;
      background-color: #eee;
      padding: 10px;
      border-radius: 10px;
      .item {
        font-size: 24px;
        display: flex;
        align-items: center;
        background-color: #fff;
        margin-bottom: 10px;
        padding: 10px 5px;
        border-radius: 50px;
        border-bottom: 1px solid gray;
        .content {
          width: 85%;
          margin: 0 5px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          &:hover {
            color: #e30707;
          }
        }
        .date {
          position: absolute;
          right: 20px;
          bottom: 0;
          font-size: 12px;
        }
      }
    }
  }
}
</style>
